<template>
  <div class="app-container">
    <el-tabs v-model="activeName"  type="card" @tab-click="handleClick">
      <el-tab-pane label="待支付" name="0"></el-tab-pane>
      <el-tab-pane label="待处理" name="1"></el-tab-pane>
      <el-tab-pane label="进行中" name="2"></el-tab-pane>
      <el-tab-pane label="已注册" name="3"></el-tab-pane>
      <el-tab-pane label="无效" name="4"></el-tab-pane>
    </el-tabs>
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="86px">
      <el-form-item label="申请类型" prop="patentApplyType">
        <el-select v-model="queryParams.patentApplyType" placeholder="请选择申请类型" clearable size="small">
          <el-option
            v-for="dict in patentApplyTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="公司名称" prop="patentCompanyName">
        <el-input
          v-model="queryParams.patentCompanyName"
          placeholder="请输入公司名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否有图纸" prop="patentWgzlsfytz">
        <el-select v-model="queryParams.patentWgzlsfytz" placeholder="请选择是否有设计图纸" clearable size="small">
          <el-option
            v-for="dict in patentWgzlsfytzOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
      <el-form-item>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['web:patent:add']"
            >新增
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['web:patent:edit']"
            >修改
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['web:patent:remove']"
            >删除
            </el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['web:patent:export']"
            >导出
            </el-button>
          </el-col>
        </el-row>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="patentList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <!--申请信息-->
      <el-table-column label="申请信息" align="left" width="180">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>申请类型: <span v-if="scope.row.patentApplyType == '0'">公司</span><span v-if="scope.row.patentApplyType != '0'">个人</span></p>
            <p>名称: {{ scope.row.patentCompanyName }} {{ scope.row.patentSqrxing }} {{ scope.row.patentSqrming }}</p>
            <p>邮箱: {{ scope.row.patentEmail }}</p>
            <p>国家: {{ scope.row.patentCounty }}</p>
            <p>省市区: {{ scope.row.patentProvince }}{{ scope.row.patentCity }}{{ scope.row.patentArea }}</p>
            <p>详细地址: {{ scope.row.patentAddress }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.patentCompanyName }} {{ scope.row.patentSqrxing }} {{ scope.row.patentSqrming }}</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>

      <!--发明人信息-->
      <el-table-column label="是否一致" align="center" prop="patentFmrshisqr" :formatter="patentFmrshisqrFormat"/>
      <el-table-column label="申请人" align="center">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <p>申请人: {{ scope.row.patentFmrxing }} {{ scope.row.patentFmrming }}</p>
            <p>邮箱: {{ scope.row.patentFmrEmail }}</p>
            <p>国家: {{ scope.row.patentFmrCounty }}</p>
            <p>省市区: {{ scope.row.patentFmrProvince }}{{ scope.row.patentFmrCity }}{{ scope.row.patentFmrArea }}</p>
            <p>详细地址: {{ scope.row.patentFmrAddress }}</p>
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">{{ scope.row.patentFmrxing }} {{ scope.row.patentFmrming }}</el-tag>
            </div>
          </el-popover>

        </template>
      </el-table-column>

      <!--外观专利-->
      <el-table-column label="是否有图纸" align="center" prop="patentWgzlsfytz" :formatter="patentWgzlsfytzFormat"/>
      <el-table-column label="图纸信息" align="center">
        <template slot-scope="scope">
          <span style="color: #00afff;cursor: pointer;" @click="sjtpMethod(scope.row)">查看</span>
        </template>
      </el-table-column>

      <!--图纸费用-->
      <el-table-column label="说明" align="center" prop="patentContent"/>
      <el-table-column label="价格" align="center" prop="patentMoney"/>

      <el-table-column label="支付状态" align="center" prop="patentPayStatus" :formatter="patentPayStatusFormat"/>
      <el-table-column label="支付时间" align="center" prop="patentPayTime"/>
      <el-table-column label="审核状态" align="center" prop="patentStatus" :formatter="patentStatusFormat"/>
      <el-table-column label="文件信息" align="center" prop="patentFile1">
        <template slot-scope="scope">
          <span style="color: #00afff;cursor: pointer;" @click="wjxxMethod(scope.row)">查看</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['web:patent:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['web:patent:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改专利实体对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="560px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请类型" prop="patentApplyType">
          <el-select v-model="form.patentApplyType" @change="sqlxChange" placeholder="请选择申请类型" style="width: 100%;">
            <el-option
              v-for="dict in patentApplyTypeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="公司名称" prop="patentCompanyName">
          <el-input v-model="form.patentCompanyName" placeholder="请输入公司名称"/>
        </el-form-item>

        <el-row v-show="sqrsfxs">
          <el-col :span="12">
            <el-form-item label="申请人姓" prop="patentSqrxing">
              <el-input v-model="form.patentSqrxing" placeholder="请输入申请人姓"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人名" prop="patentSqrming">
              <el-input v-model="form.patentSqrming" placeholder="请输入申请人名"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="邮箱" prop="patentEmail">
          <el-input v-model="form.patentEmail" placeholder="请输入邮箱"/>
        </el-form-item>

        <el-row>
          <el-col :span="12">
            <el-form-item label="国家" prop="patentCounty">
              <el-input v-model="form.patentCounty" placeholder="请输入国家"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮编" prop="patentYoubian">
              <el-input v-model="form.patentYoubian" placeholder="请输入邮编"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="省市区" prop="selectOption1">
          <SelectSsx v-model="form.selectOption1" style="width: 100%;"/>
        </el-form-item>
        <el-form-item label="详细地址" prop="patentAddress">
          <el-input v-model="form.patentAddress" placeholder="请输入详细地址"/>
        </el-form-item>


        <el-form-item label="是否一致" prop="patentFmrshisqr">
          <el-select v-model="form.patentFmrshisqr" :disabled="!sfyzkbj" placeholder="请选择发明人与申请人是否一致" style="width: 100%;">
            <el-option
              v-for="dict in patentFmrshisqrOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>


        <div v-show="!sqryfmrsfyz">
          <el-row>
            <el-col :span="12">
              <el-form-item label="发明人姓" prop="patentFmrxing">
                <el-input v-model="form.patentFmrxing" placeholder="请输入申请人姓"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="发明人名" prop="patentFmrming">
                <el-input v-model="form.patentFmrming" placeholder="请输入发明人名"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="邮箱" prop="patentFmrEmail">
            <el-input v-model="form.patentFmrEmail" placeholder="请输入邮箱"/>
          </el-form-item>

          <el-row>
            <el-col :span="12">
              <el-form-item label="国家" prop="patentFmrCounty">
                <el-input v-model="form.patentFmrCounty" placeholder="请输入国家"/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮编" prop="patentFmrYoubian">
                <el-input v-model="form.patentFmrYoubian" placeholder="请输入邮编"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item label="省市区" prop="patentAddress">
            <SelectSsx v-model="form.selectOption2" style="width: 100%;"/>
          </el-form-item>
          <el-form-item label="详细地址" prop="patentAddress">
            <el-input v-model="form.patentFmrAddress" placeholder="请输入详细地址"/>
          </el-form-item>
        </div>

        <el-form-item label="是否有图纸" prop="patentWgzlsfytz">
          <el-select v-model="form.patentWgzlsfytz" placeholder="请选择是否有设计图纸" style="width: 100%;">
            <el-option
              v-for="dict in patentWgzlsfytzOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-row>
          <el-col :span="12">
            <el-form-item label="上面">
              <uploadImage v-model="form.patentWgzlshang"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下面">
              <uploadImage v-model="form.patentWgzlxia"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="左面">
              <uploadImage v-model="form.patentWgzlzuo"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="右面">
              <uploadImage v-model="form.patentWgzlyou"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="前面">
              <uploadImage v-model="form.patentWgzlqian"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="后面">
              <uploadImage v-model="form.patentWgzlhou"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item label="说明">
          <el-input v-model="form.patentContent" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <!-- 专利图片 -->
    <el-dialog
      :title="sjtpTitle"
      :visible.sync="sjtpOpen"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">
      <el-form size="mini" label-position="top" label-width="140px">

        <el-row>
          <el-col :span="8">
            <el-form-item label="前">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlqian"
                :preview-src-list="[form.patentWgzlqian]">
              </el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="后">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlhou"
                :preview-src-list="[form.patentWgzlhou]">
              </el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="左">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlzuo"
                :preview-src-list="[form.patentWgzlzuo]">
              </el-image>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="右">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlyou"
                :preview-src-list="[form.patentWgzlyou]">
              </el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlshang"
                :preview-src-list="[form.patentWgzlshang]">
              </el-image>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="下">
              <el-image
                style="width: 130px; height: auto;"
                :src="form.patentWgzlxia"
                :preview-src-list="[form.patentWgzlxia]">
              </el-image>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>



    <!-- 平台上传图片 -->
    <el-dialog
      :title="wjxxTitle"
      :visible.sync="wjxxOpen"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
      v-dialogDrag
      class="my_dialog">
      <el-form ref="form" :model="form" size="mini" label-width="68px">
        <el-tabs type="card">
          <el-tab-pane label="注册文件">
            <el-form-item label="注册文件">
              <single-upload v-model="form.patentFile1" @input="onInput()"/>
            </el-form-item>
            <!--              <el-image
                            style="height: 340px;"
                            :src="form.companyFile1"
                            :preview-src-list="[form.companyFile1]">
                            <single-upload v-model="form.otherFiles[index].qtwjPath" @input="onInput()"/>
                        </el-image>-->
          </el-tab-pane>
          <el-tab-pane label="受理回执">
            <el-form-item label="受理回执">
              <single-upload v-model="form.patentFile2" @input="onInput()"/>
            </el-form-item>
            <!--            <el-image
                        style="height: 340px;"
                        :src="form.companyFile2"
                        :preview-src-list="[form.companyFile2]">
                      </el-image>-->
          </el-tab-pane>
          <el-tab-pane label="其他文件">
            <span style="color: #00afff;cursor: pointer;margin-bottom: 15px;" @click="addOtherFile()">添加</span>
            <div v-for="(item,index) in this.form.otherFiles" :key="index">
              <el-form-item label="文件名称">
                <el-input v-model="form.otherFiles[index].qtwjTitle" @input="onInput()" placeholder="请输入标题" style="width: 100%;"/>
              </el-form-item>
              <el-form-item label="文件说明">
                <el-input v-model="form.otherFiles[index].qtwjContent" @input="onInput()" type="textarea" placeholder="请输入内容" />
              </el-form-item>
              <el-form-item>
                <span slot="label">
                  文件上传<br>
                  <span style="color: red;cursor: pointer;margin-bottom: 15px;" @click="deleteWj(index);">刪除</span>
                </span>
                <single-upload v-model="form.otherFiles[index].qtwjPath" @input="onInput()"/>
              </el-form-item>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import {listPatent, getPatent, delPatent, addPatent, updatePatent, exportPatent} from "@/api/sbxm/patent/patent";
import UploadImage from '@/components/UploadImage';
import SelectSsx from "../../../components/SelectSsx";
import SingleUpload from "../../../components/UploadImage/singleUpload";

export default {
  name: "Patent",
  components: {
    SingleUpload,
    SelectSsx,
    UploadImage,
  },
  data() {
    return {
      activeName:"0",
      // 遮罩层
      loading: true,
      sqryfmrsfyz: true,
      sfyzkbj: true,
      sqrsfxs: false,

      sjtpTitle: "",
      sjtpOpen: false,

      wjxxOpen: false,
      wjxxTitle: "",

      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 专利实体表格数据
      patentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,

      // 申请类型字典
      patentApplyTypeOptions: [],
      // 发明人与申请人是否一致字典
      patentFmrshisqrOptions: [],
      // 支付状态字典
      patentPayStatusOptions: [],
      // 审核状态字典
      patentStatusOptions: [],
      // 是否有设计图纸字典
      patentWgzlsfytzOptions: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        patentApplyType: null,
        patentCompanyName: null,
        patentWgzlsfytz: null,
      },
      // 表单参数
      form: {
        patentFmrshisqr: "0",
        selectOption1: {},
        selectOption2: {},
        otherFiles:[]
      },
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
    this.getDicts("applyTypeCode").then(response => {
      this.patentApplyTypeOptions = response.data;
    });
    this.getDicts("shifouCode").then(response => {
      this.patentFmrshisqrOptions = response.data;
    });
    this.getDicts("payStatusCode").then(response => {
      this.patentPayStatusOptions = response.data;
    });
    this.getDicts("patentStatusCode").then(response => {
      this.patentStatusOptions = response.data;
    });
    this.getDicts("shifouCode").then(response => {
      this.patentWgzlsfytzOptions = response.data;
    });
  },
  methods: {
    /** 查询专利实体列表 */
    getList() {
      this.loading = true;
      listPatent(this.queryParams).then(response => {
        console.log(response)
        this.patentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    handleClick(e){
      this.activeName = e.index;
      this.getList();
    },

    sqlxChange(e) {
      if (e == "0") {
        //公司
        this.form.patentFmrshisqr = "1";
        this.sqryfmrsfyz = false;
        this.sfyzkbj = false;
        this.sqrsfxs = false;
      } else {
        this.form.patentFmrshisqr = "0";
        this.sqryfmrsfyz = true;
        this.sfyzkbj = true;
        this.sqrsfxs = true;
      }
    },

    wjxxMethod(row) {
      getPatent(row.id).then(response => {
        this.form = response.data;
        this.wjxxOpen = true;
        this.wjxxTitle = "查看专利信息";
      });
    },


    sjtpMethod(row) {
      getPatent(row.id).then(response => {
        this.form = response.data;
        this.sjtpOpen = true;
        this.sjtpTitle = "查看图纸信息";
      });
    },

    // 申请类型字典翻译
    showColnum(row, column) {
      console.log(column);
      return row.patentApplyType == 0;
    },

    // 申请类型字典翻译
    patentApplyTypeFormat(row, column) {
      return this.selectDictLabel(this.patentApplyTypeOptions, row.patentApplyType);
    },
    // 发明人与申请人是否一致字典翻译
    patentFmrshisqrFormat(row, column) {
      return this.selectDictLabel(this.patentFmrshisqrOptions, row.patentFmrshisqr);
    },
    // 支付状态字典翻译
    patentPayStatusFormat(row, column) {
      return this.selectDictLabel(this.patentPayStatusOptions, row.patentPayStatus);
    },
    // 审核状态字典翻译
    patentStatusFormat(row, column) {
      return this.selectDictLabel(this.patentStatusOptions, row.patentStatus);
    },
    // 是否有设计图纸字典翻译
    patentWgzlsfytzFormat(row, column) {
      return this.selectDictLabel(this.patentWgzlsfytzOptions, row.patentWgzlsfytz);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        beginTime: null,
        createBy: null,
        createTime: null,
        endTime: null,
        remark: null,
        searchValue: null,
        updateBy: null,
        updateTime: null,
        patentAddress: null,
        patentApplyType: null,
        patentArea: null,
        patentCity: null,
        patentCode: null,
        patentCompanyName: null,
        patentContent: null,
        patentCounty: null,
        patentEmail: null,
        patentFmrAddress: null,
        patentFmrArea: null,
        patentFmrCity: null,
        patentFmrCode: null,
        patentFmrCounty: null,
        patentFmrEmail: null,
        patentFmrProvince: null,
        patentFmrming: null,
        patentFmrshisqr: null,
        patentFmrxing: null,
        patentMoney: null,
        patentPayStatus: null,
        patentPayTime: null,
        patentProvince: null,
        patentSqrming: null,
        patentSqrxing: null,
        patentStatus: "0",
        patentWgzlhou: null,
        patentWgzlqian: null,
        patentWgzlsfytz: null,
        patentWgzlshang: null,
        patentWgzlxia: null,
        patentWgzlyou: null,
        patentWgzlzuo: null,
        patentYoubian: null,
        patentFile1: null,
        patentFile2: null,
        selectOption1: {},
        selectOption2: {},
        otherFiles:[],
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加专利实体";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getPatent(id).then(response => {
        this.form = response.data;
        if (this.form.patentCode != null && this.form.patentCode != '') {
          this.form.selectOption1 = {};
          this.form.selectOption1.code = this.form.patentCode;
          this.form.selectOption1.name = this.form.patentProvince+","+this.form.patentCity+","+this.form.patentArea;
        }
        if (this.form.patentFmrCode != null && this.form.patentFmrCode != '') {
          this.form.selectOption2 = {};
          this.form.selectOption2.code = this.form.patentFmrCode;
          this.form.selectOption2.name = this.form.patentFmrProvince+","+this.form.patenFmrtCity+","+this.form.patentFmrArea;
        }
        this.open = true;
        this.title = "修改专利实体";
      });
    },


    /** 查看证件 */
    addOtherFile() {
      console.log(this.form)
      if(!this.form.otherFiles){
        this.form.otherFiles=[]
      }
      this.form.otherFiles.push({qtwjTitle:"",qtwjPath:"",qtwjContent:"",objId: this.form.id});
      this.$forceUpdate();
    },

    deleteWj(index){
      this.form.otherFiles.splice(index,1);
      this.$forceUpdate();
      console.log(this.form.otherFiles)
    },


    onInput(){
      this.$forceUpdate();
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        console.log(this.form)
        if (this.form.selectOption1 != null) {
          this.form.patentCode = this.form.selectOption1.code;
          var arras = this.form.selectOption1.name.split(",");
          this.form.patentProvince = arras[0];
          this.form.patentCity = arras[1];
          this.form.patentArea = arras[2];
        }
        if (this.form.selectOption2 != null) {
          this.form.patentFmrCode = this.form.selectOption2.code;
          var arras = this.form.selectOption1.name.split(",");
          this.form.patentFmrProvince = arras[0];
          this.form.patentFmrCity = arras[1];
          this.form.patentFmrArea = arras[2];
        }
        if (valid) {
          if (this.form.id != null) {
            updatePatent(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                if(this.open){
                  this.open = false;
                  this.getList();
                }else{
                  this.wjxxOpen = false;
                }
              }
            });
          } else {
            addPatent(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除吗?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delPatent(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(function () {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有专利实体数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportPatent(queryParams);
      }).then(response => {
        this.download(response.msg);
      }).catch(function () {
      });
    }
  }
};
</script>
